package cn.lili.controller.user;

import cn.lili.common.utils.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.member.service.VipConfigService;
import cn.lili.modules.system.entity.dos.LiVipConfig;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "会员配置管理")
@RequestMapping("/user/vipconfig")
public class VipConfigController {
    @Autowired
    private VipConfigService configService;

    /**
     * 获取会员配置列表
     * @return
     */
    @ApiModelProperty(value = "会员配置列表")
    @GetMapping("/list")
    public ResultMessage<Object> getList(){
        return configService.getList();
    }

    /**
     * 会员配置修改
     * @param liVipConfig
     * @return
     */
    @ApiModelProperty(value = "会员配置修改")
    @PutMapping("/update")
    public ResultMessage<Object> configUpdate(@RequestBody LiVipConfig liVipConfig){
       return configService.configUpdate(liVipConfig);
    }

    /**
     * 会员支付方式修改
     * @param payWay
     * @param id
     * @return
     */
    @ApiModelProperty(value = "会员支付方式修改")
    @PutMapping("/payway")
    public ResultMessage<Object> updatePayWay(@RequestParam String payWay,
                                              @RequestParam String id){
        return configService.updatePayWay(payWay,id);
    }

    /**
     * 会员配置添加
     */
    @ApiModelProperty(value = "会员配置添加")
    @PostMapping("/add")
    public ResultMessage<Object> addVipConfig(@RequestBody LiVipConfig vipConfig){
       return configService.saveConfig(vipConfig);
    }

    @ApiModelProperty(value = "获取会员默认配置")
    @GetMapping("getDefaultVip")
    public ResultMessage<Object> getDefaultVip () {
        return ResultUtil.data(configService.getByDefault());
    }
}
